﻿using FluentMigrator;

namespace BP.Plugin.Monitor.Infrastructure.Persistence.Migrations.OnlineUsers;

[Migration(202511082207)]
public class CreateTable : ForwardOnlyMigration
{
    public override void Up()
    {
        Create.Table("OnlineUsers")
            .InSchema(SchemaNames.Monitor)
            .WithColumn("Id").AsInt64().PrimaryKey().Identity().WithColumnDescription("主键")
            .WithColumn("TenantId").AsString(100).Nullable().WithColumnDescription("租户标识")
            .WithColumn("UserId").AsGuid().NotNullable().WithColumnDescription("用户 ID")
            .WithColumn("UserName").AsString(100).NotNullable().WithColumnDescription("用户名")
            .WithColumn("IP").AsString(50).Nullable().WithColumnDescription("登录 IP")
            .WithColumn("Address").AsString(200).Nullable().WithColumnDescription("登录地点")
            .WithColumn("System").AsString(100).Nullable().WithColumnDescription("操作系统")
            .WithColumn("Browser").AsString(100).Nullable().WithColumnDescription("浏览器类型")
            .WithColumn("LoginTime").AsDateTimeOffset().NotNullable().WithColumnDescription("登录时间")
            .WithColumn("LastActiveTime").AsDateTimeOffset().NotNullable().WithColumnDescription("最后活跃时间")
            .WithColumn("IsOnline").AsBoolean().NotNullable().WithColumnDescription("是否在线");
    }
}
